#!/usr/bin/env python3
import sys

lookup = {
    '(': (1, 0, 0, 0),
    ')': (-1, 0, 0, 0),
    '[': (0, 1, 0, 0),
    ']': (0, -1, 0, 0),
    '{': (0, 0, 1, 0),
    '}': (0, 0, -1, 0),
    '<': (0, 0, 0, 1),
    '>': (0, 0, 0, -1)
}

expected = {
    ')': '(',
    ']': '[',
    '}': '{',
    '>': '<'
}

score = {
    ')': 3,
    ']': 57,
    '}': 1197,
    '>': 25137
}

balance = 0
for line in sys.stdin:
    # round, square, curly, angle (denoted by lookup)
    brackets = (0, 0, 0, 0)
    stack = []
    print(line.rstrip('\n'))
    for c in line.rstrip('\n'):
        closing = sum(lookup[c]) < 0
        brackets = [ sum(x) for x in zip(brackets, lookup[c]) ]
        print('  ' * (sum(brackets) + (1 if closing else 0)), c, brackets, lookup[c])
        if not closing:
            stack.append(c)
        else:
            if stack[-1] != expected[c]:
                print(f'closure incorrect: {stack[-1]} == {expected[c]} = {stack[-1] == expected[c]}')
                balance += score[c]
            stack.pop()
    print(f'final bracket balance {brackets}')
    # code to complete line
print(f'file gets a score of {balance}')
